// $codepro.audit.disable

import java.sql.Date;
import java.util.ArrayList;
import java.util.List;


public class ConnectGTD {
    
    public ConnectGTD(){
        
    }
    MyQuery client = new MyQuery();
    User currentUser = new User();
    String search;
    String myUsername;
    String myPassWord;
    boolean isTrue;
    User user;
    Appointment app;
    ArrayList<User> users;
    ArrayList<Appointment> appointments;
    Appointment appointment;
    TreatmentRecord record;
    DoctorsOrders orders;
    Date date;
    String name;
    
    public void setUsername(String input)
    {
        myUsername = input;
    }
    
    public void setPassWord(String input)
    {
        myPassWord = input;
    }
    
    public String getUsername()
    {
        return myUsername;
    }
    public String getPassWord()
    {
        return myPassWord;
    }
    public void setTrue (boolean input)
    {
        isTrue = input;
    }
    
    public boolean trueTest(){
        return isTrue;
    }
    
    public User getUser(){
        return user;
    }
    public void setUser(User input){
        user = input;
    }
    
    public void setUsers(ArrayList<User> input)
    {
        users = input;
    }
    public ArrayList<User> getUsers()
    {
        return users;
    }
    
    public void setSearch(String input)
    {
        search = input;
    }
    
    public void setAppointment(ArrayList<Appointment> input)
    {
        appointments = input;
    }
    
    public ArrayList<Appointment> getAppointments()
    {
        return appointments;
    }
    
    public void setDoctorsOrders(DoctorsOrders input)
    {
        orders = input;
    }
    
    public DoctorsOrders getDoctorsOrders()
    {
        return orders;
    }
    
    public void setTreatmentRecord(TreatmentRecord input)
    {
        record = input;
    }
    
    public TreatmentRecord getTreatmentRecord()
    {
        return record;
    }
    
    public void setDate(Date input)
    {
        date = input;
    }
    
    public Date getDate()
    {
        return date;
    }
    
    public User getCurrentUser(){
    	
        return currentUser;
    }
    public void setCurrentUser(User input){
        currentUser = input;
    }
    
    public void setAppointment(Appointment input){
        app = input;
    }
    
    public User login(String role){
        int i = 0;
        if (role == "patient"){
            i=1;}
        if (role == "doctor"){
            i=2;}
        if (role == "nurse"){
            i=3;}
        if (role == "admin"){

            i=4;}
        Login login = new Login(myUsername, myPassWord, i);
        return login.authenticate();

        
    }
    
    public void addUser(){
        client.addUser(user);
    }
    public void editUser(){
        client.updateUser(user, user.getSSN());
    }
    public List<User> getUserSearch()
    {
        return client.searchUserByName(name);
    }
    public List<Appointment> getAppointmentsSearch(){
        return client.searchUserAppointmentDateOnly(date);
    }
    public List<Appointment> getOwnAppointments(){

        return client.searchUserAppointmentDate(currentUser.getSSN(), date);

    }
    
    public void setName(String input){
        name = input;
    }
    
    public void deleteUser(){
    	System.out.println(user.getSSN());
        client.deleteUser(user.getSSN());
    }
    public void setNames(String input){
    	name=input;
    }
    
    public List<TreatmentRecord> getTreatmentRecords(){
    	return client.getTreatmentRecords(currentUser.getSSN());
    }
    public void makeApp(Appointment input){
        input.setPatient(currentUser.getName());
    	client.addAppointment(currentUser.getSSN(), input);
    }

}

